package com.hfut.wxy.dao;

import com.hfut.wxy.common.parent.ParentDao;
import com.hfut.wxy.entity.mysql.WxyOrderException;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;


public interface WxyOrderExceptionDao extends ParentDao<WxyOrderException,Integer> {
    @Modifying
    @Transactional
    @Query(nativeQuery = true,value = "DELETE  FROM wxyexception WHERE orderId = ?1 order by id desc limit 1")
    void deleteByOrderIdAndUserId(Integer orderId);

    @Query(nativeQuery = true,value = "select * from wxyexception where orderId=?1 order by id desc limit 1")
    WxyOrderException findAllByOrderIdOrderByIdDesc(Integer orderId);

    long countAllByUserIdAndIsOrderCreator(Integer userId, boolean isOrderCreator);
}
